 <template>
  <div class="account-wrapper">
    <centerHeader/>

    <div class="account-wrap">
      <div class="main-wrap">
        <div class="centerCate-wrap">
          <ul>
            <li>
              <p>
                <!-- <router-link :to="{ name: 'order', params: {} }"> -->
                <span class="title-01">门店名称</span>
                <!-- <i class="icon iconfont icon-right1 icon-02"></i> -->
                <span class="title-02">{{user_info.store_name}}</span>
                <!-- </router-link> -->
              </p>
            </li>

            <li v-if="user_info.user_type != 0">
              <p>
                <router-link :to="{ name: 'password', params: {} }">
                  <span class="title-01">修改密码</span>
                  <i class="icon iconfont icon-right1 icon-02"></i>
                  <span class="title-02"></span>
                </router-link>
              </p>
            </li>
          </ul>
        </div>

        <div class="account-box">
          <p class="account-txt" @click="logout">退出登录</p>
        </div>
      </div>
    </div>

    <centerFooter/>
  </div>
</template>

 <script type="text/ecmascript-6">
import centerHeader from "@/views/center/components/centerHeader";
import centerFooter from "@/views/center/components/centerFooter";
import constant from "@/utils/constant.js";
// 引用API文件
import http from "@/utils/http.js";

export default {
  name: "store_account",
  data() {
    return {
      user_info: {},
      user_type: ""
    };
  },
  components: {
    centerHeader,
    centerFooter
  },
  methods: {
    logout() {
      localStorage.removeItem("user_token");
      localStorage.removeItem("user_name");
      localStorage.removeItem("user_type");
      window.location.href = "/";
    },
    userinfo() {
      http.get(this, {
        url: "ucenter/user_info",
        data: {
          token: localStorage.getItem("user_token")
        },
        dataType: "json",
        success: function(data) {
          console.log("用户信息:", data);
          if (data.status == 1) {
            this.user_info = data.info;
          } else {
          }
        }
      });
    },
    storeinfo() {
      http.get(this, {
        url: "store/store_info",
        data: {
          token: localStorage.getItem("user_token")
        },
        dataType: "json",
        success: function(data) {
          console.log("门店信息:", data);
          if (data.status == 1) {
            this.user_info = data.info;
            this.user_type = "store";
            // this.total_commission = data.info.total_commission;
            // this.store_count = data.info.store_count;
            localStorage.setItem("user_name", data.info.store_name);
            //localStorage.setItem("user_head", data.info.headimgurl);
            localStorage.setItem("user_type", "store");
          } else {
          }
        }
      });
    }
  },
  created() {},
  activated() {
    this.user_type = localStorage.getItem("user_type");
    if (this.user_type == "store") {
      this.storeinfo();
    } else {
      this.userinfo();
    }
  }
};
</script>

 <style scoped lang="scss">
.account-wrapper {
}

.main-wrap {
  margin-bottom: -0.22rem;
  .centerCate-wrap {
    width: 100%;

    ul {
      width: 100%;
      $letHeight: 0.75rem;

      li {
        border-top: 0.02rem solid $c-gray-dark;
        line-height: $letHeight;
        padding: 0 0.35rem;

        p {
          color: $c-mainC;
          @extend .cmm-clearfix;
          height: $letHeight;

          * {
            line-height: $letHeight;
            display: inline-block;
            vertical-align: middle;
          }

          a {
            width: 100%;
          }
          .icon-02 {
            font-size: 0.3rem;
            float: right;
            font-weight: bold;
          }
          .title-01 {
            font-size: 0.3rem;
            float: left;
          }

          .title-02 {
            font-size: 0.22rem;
            float: right;
            width: 3.4rem;
            text-align: right;
            padding-right: 0.26rem;
          }
        }
      }
    }
  }
}

.account-box {
  text-align: center;
  width: 100%;

  .account-txt {
    width: 100%;
    border-radius: 0rem;
    background-color: $c-gray-dark;
    font-size: 0.32rem;
    color: $c-mainC;
    $letHeight: 0.8rem;
    height: $letHeight;
    line-height: $letHeight;
    text-align: center;
    margin: 0rem auto;
    display: inline-block;
  }
}
</style>
